package com.ruoyi.project.yuwen.feedbackstat.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yuwen.feedbackstat.domain.FeedbackStat;
import com.ruoyi.project.yuwen.feedbackstat.service.IFeedbackStatService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 举报用户统计Controller
 * 
 * @author shixiangwen
 * @date 2021-02-28
 */
@Controller
@RequestMapping("/yuwen/feedbackstat")
public class FeedbackStatController extends BaseController
{
    private String prefix = "yuwen/feedbackstat";

    @Autowired
    private IFeedbackStatService feedbackStatService;

    @RequiresPermissions("yuwen:feedbackstat:view")
    @GetMapping()
    public String feedbackstat()
    {
        return prefix + "/feedbackstat";
    }

    /**
     * 查询举报用户统计列表
     */
    @RequiresPermissions("yuwen:feedbackstat:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FeedbackStat feedbackStat)
    {
        startPage();
        List<FeedbackStat> list = feedbackStatService.selectFeedbackStatList(feedbackStat);
        return getDataTable(list);
    }

    /**
     * 导出举报用户统计列表
     */
    @RequiresPermissions("yuwen:feedbackstat:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FeedbackStat feedbackStat)
    {
        List<FeedbackStat> list = feedbackStatService.selectFeedbackStatList(feedbackStat);
        ExcelUtil<FeedbackStat> util = new ExcelUtil<FeedbackStat>(FeedbackStat.class);
        return util.exportExcel(list, "feedbackstat");
    }

    /**
     * 新增举报用户统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存举报用户统计
     */
    @RequiresPermissions("yuwen:feedbackstat:add")
    @Log(title = "举报用户统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FeedbackStat feedbackStat)
    {
        return toAjax(feedbackStatService.insertFeedbackStat(feedbackStat));
    }

    /**
     * 修改举报用户统计
     */
    @GetMapping("/edit/{uid}")
    public String edit(@PathVariable("uid") Long uid, ModelMap mmap)
    {
        FeedbackStat feedbackStat = feedbackStatService.selectFeedbackStatById(uid);
        mmap.put("feedbackStat", feedbackStat);
        return prefix + "/edit";
    }

    /**
     * 修改保存举报用户统计
     */
    @RequiresPermissions("yuwen:feedbackstat:edit")
    @Log(title = "举报用户统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FeedbackStat feedbackStat)
    {
        return toAjax(feedbackStatService.updateFeedbackStat(feedbackStat));
    }

    /**
     * 删除举报用户统计
     */
    @RequiresPermissions("yuwen:feedbackstat:remove")
    @Log(title = "举报用户统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(feedbackStatService.deleteFeedbackStatByIds(ids));
    }
}
